package org.aplombh.java.leetcode.dailyTopic;

public class _754到达终点数字 {
    public static void main(String[] args) {
        System.out.println(new Solution754_1().reachNumber(2));
    }
}

class Solution754_1 {
    public int reachNumber(int target) {

        target = Math.abs(target);

        int n = 0;

        while (target > 0) {

            n++;
            target -= n;

        }

        return target % 2 == 0 ? n : n + 1 + n % 2;
    }
}